﻿using System.Collections.Generic;
using System.Linq;
using Norm.Attributes;

namespace FVG.Entities.ClientInformation
{
	public class Website : ChildIdentifiableEntity, INamedEntity
	{
		#region Fields

		private IList<Domain> _primaryDomains;

		#endregion

		#region Constructors

		public Website()
		{
			Domains = new List<Domain>();
		}

		#endregion

		#region Properties

		public string Name { get; set; }

		public IList<Domain> Domains { get; set; }

		public WebsiteType Type { get; set; }

		[MongoIgnore]
		public IList<Domain> PrimaryDomains
		{
			get
			{
				if (_primaryDomains == null && Domains.Count > 0)
				{
					_primaryDomains = Domains.Where(d => d.IsPrimary).ToList();
				}

				return _primaryDomains;
			}
		}

		#endregion
	}
}
